const gulp = require("gulp");
const sass = require("gulp-sass");
const connect = require("gulp-connect");

gulp.task("copy", done => {
    gulp.src("*.html").pipe(gulp.dest("dist")).pipe(connect.reload());
    done();
});
gulp.task("copyjs", done => {
    gulp.src("js/*.js").pipe(gulp.dest("dist/js")).pipe(connect.reload());
    done();
});
gulp.task("copyimg", done => {
    gulp.src("img/**").pipe(gulp.dest("dist/img")).pipe(connect.reload());
    done();
});
gulp.task("sass", done => {
    gulp.src("sass/*.scss").pipe(sass()).pipe(gulp.dest("dist/css")).pipe(connect.reload());
    done();
});
gulp.task("server", done => {
    connect.server({
        root: "dist",
        livereload: true
    })
    done();
})
gulp.task("watch", done => {
    gulp.watch("*.html", gulp.series("copy"));
    gulp.watch("sass/*.scss", gulp.series("sass"));
    gulp.watch("js/*.js", gulp.series("copyjs"));
    gulp.watch("img/**", gulp.series("copyimg"));
    done();
})
gulp.task("default", gulp.series("watch", "server"))